﻿using InnoWeb.CEND.BL.Infrastructure;
using InnoWeb.CEND.Core.Model.iThink;
using InnoWeb.CEND.Data;
using InnoWeb.CEND.Data.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InnoWeb.CEND.BL.Service.iThink
{
    class iThinkItemService: IService<iThinkItems>
    {
        private readonly GenericRepository<iThinkItems> _iThinkItemRepository;
        private readonly IUnitOfWork _unitOfWork;

        public iThinkItemService(IUnitOfWork unitOfWork, GenericRepository<iThinkItems> newsItemRepository)
        {
            this._iThinkItemRepository = newsItemRepository;
            this._unitOfWork = unitOfWork;
        }

        public IQueryable<iThinkItems> GetAllElements()
        {
            return _iThinkItemRepository.GetAll();
        }

        public iThinkItems GetElementById(int id)
        {
            return _iThinkItemRepository.GetById(id);
        }

        public void CreateElement(iThinkItems entity)
        {
            _iThinkItemRepository.Insert(entity);
        }

        public void UpdateElement(iThinkItems entity)
        {
            _iThinkItemRepository.Update(entity);
        }

        public void DeleteElement(int id)
        {
            _iThinkItemRepository.Delete(id);
        }

        public void SaveChanges()
        {
            _unitOfWork.SaveChanges();
        }
    }
}
